<!-- 待核查 -->
<template>
    <div class="regularInspectionsEtid">
      <div style="width: 100%;height: 100%;" v-show="!isVantList">
        <div class="tab">
          <ul>
            <li v-for="(item, index) in tabArr" :class="{ select: nowIndex === index }" :key="index"
              @click="tabClick(index)">
              <p>{{ item }}</p>
              <span v-if="nowIndex === index"
                style="width: 64px; height: 6px; background: #007aff; border-radius: 3px; display: inline-block">
              </span>
            </li>
          </ul>
        </div>
        <div class="content" v-show="nowIndex == 0">
          <patrol-information :objectNo="row.objectNo" v-if="row.objectNo" :disabled="true"></patrol-information>
        </div>
        <div class="content" v-show="nowIndex == 1">
          <house-safety-checklist ref="houseSafety" v-if="row.objectNo" :rowData="row" :objectNo="row.objectNo"
            :disabled="disabled">
          </house-safety-checklist>
        </div>
        <p style="margin-top:10px;text-align: center;padding: 0 10px;">
          <van-button size="small" type="info" v-if="buttonshow" @click="save()">保存</van-button>
          <van-button size="small" type="info" v-if="buttonshow" @click="submit()">提交 </van-button>
          <van-button size="small" type="info" @click="historyList()">历史核查记录 </van-button>
        </p>
      </div>
      <vantList v-if="isVantList" :checkNumber="this.$refs.houseSafety.JBXXform.checkNumber" :id="row.id"
        @close="isVantList = false">
      </vantList>
    </div>
  </template>
  <script>
//   import dd from 'gdt-jsapi'
  import patrolInformation from "./patrolInformation";
  import houseSafetyChecklist from "./houseSafetyChecklist";
  import vantList from "./vantListNew.vue";
  export default {
    name: 'regularInspectionsEtid',
    data() {
      return {
        tabArr: ['排查信息', '镇街排查'],
        nowIndex: 1,
        row: {},
        isVantList: false,
        buttonshow: true,
        type: "",
        loading: false,
        disabled: false,
      }
    },
    components: {
      patrolInformation,
      houseSafetyChecklist,
      vantList
    },
    methods: {
      handleClick() { },
      tabClick(index) {
        this.nowIndex = index
      },
      //保存
      save() {
        let _this = this
        _this.$refs.houseSafety.saveData()
      },
      //提交
      submit() {
        this.$refs.houseSafety.saveData('submit')
        setTimeout(() => {
          // this.backHomepage()
        }, 500)
      },
      // 历史核查记录
      historyList() {
        let checkNumber = this.$refs.houseSafety.JBXXform.checkNumber
        if (checkNumber) {
          this.isVantList = true
          // this.$router.push({
          //     path: '/vantList',
          //     query: {
          //         checkNumber: checkNumber,
          //     }
          // })
        } else {
          this.$toast.fail("请输入自建房排查编号!")
        }
      },
      //定位
      showGeo: async function (item) {
        let webResult = await axios.get(this.BaseURL + '/api/farmerHouse/tfwZjf/getZjfGeomP?yhfwbh=' + item.checkNumber, {
          headers: {
            isOutParam: true,
          },
        });
        if (webResult.data.data && webResult.data.data.length > 0) {
          let dataValue = [{ "geomP": webResult.data.data[0] }]
          var url = window.g.oneMapUrlLocation + "?user=" + window.localStorage.getItem("citycode") + "&data=" + encodeURIComponent(JSON.stringify(dataValue))
          window.open(url)
        } else {
          this.$toast.fail("坐标不能为空!")
        }
  
      },
    },
    mounted() {
      this.row = JSON.parse(this.$route.query.data);
      if (this.$route.query.type == 1) {
        this.disabled = true
        this.buttonshow = false
      }
      dd.ready(function () {
        dd.setTitle({
          title: '安全核查'
        })
          .then((res) => { })
          .catch((err) => {
            console.error(err)
          })
      })
    },
  }
  </script>
  <style lang="scss">
  .regularInspectionsEtid {
    width: 100%;
    height: 100%;
  
    .tab ul li {
      width: 50%;
      height: 50px;
      background: #fff;
      float: left;
      /*line-height: 50px;*/
      text-align: center;
      color: #000;
      padding-top: 10px;
    }
  
    .content {
      width: 100%;
      height: calc(100vh - 100px);
      overflow-y: auto;
    }
  
    .footer {
      width: 100%;
      padding: 20px;
      text-align: center;
    }
  
    .select {
      color: #007aff !important;
    }
  }
  </style>
  